//https://leetcode.cn/problems/minimum-size-subarray-sum/description/
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0;
        int right = 0;
        int sum = 0;
        int l = INT_MAX;

        while (right < nums.size())
        {
            sum += nums[right];

            while (sum >= target)
            {
                // cout<<"sum:"<<sum<<endl;
                // cout<<"left:"<< left<<" right:"<<right<<endl;
                l = min(right - left + 1, l);
                sum -= nums[left];
                left++;
            }
            right++;
        }

        return l == INT_MAX ? 0 : l;
    }
};